<?php

include '../connectBDD.php';
if (isset($_GET['id_event'])) {
    $id_event = $_GET['id_event'];
    $query = "DELETE FROM event WHERE id_event = '" . $id_event . "'";

    mysql_query($query) or die(mysql_error());

    $result = mysql_query("SELECT id_event, name_event, star_event FROM event");
    $nb_res = mysql_num_rows($result);
    echo "<a href=javascript:ouvrirFenetre('creationEvenement.php')>Créer un nouvel evenement</a></div>";
    echo "<div style='color:green'>$nb_res evenement(s) trouvé(s)</div>";
    if (mysql_num_rows($result) <= 0) {
        echo "<div class='no_result_found'>Aucun evenement.</div>";
    } else {
        echo "<div class='events'>";
        while ($row = mysql_fetch_assoc($result)) {

            echo"
                         <div id='event'>
                            <a href='../detailEvenement.php?idEvent=" . $row['id_event'] . "'>" . $row['name_event'] . "</a>";
                            //Si l'event est une star event on affiche l'étoile
                            if($row['star_event'] == '1'){
                                echo "<img id='star' src='../images/Star-32.png'/>";
                            }
                        
                    echo"  <div style='float:right'>
                                <a class='edit_data' href=\"javascript:ouvrirFenetre('creationEvenement.php?idEvent=" . $row['id_event']."')\"><img src='../images/Edit_Yes_32.png' /></a>
                                <a class='croix_ferm' href=\"javascript:supprimerEvenement('" . $row['id_event'] . "')\"><img src='../images/Close-32.png' height='15px' width='15px'/></a>
                            </div>
                        </div>";
        }
        echo "</div>";
    }
}
?>
